Skip to content

Conversation

nicholasdezai
Copy link

@nicholasdezai nicholasdezai commented Sep 16, 2025

Summary of the PR

This change adds GStreamer audio backend support.

Since the Rust bindings for GStreamer rely on the underlying C libraries, this change introduces additional build dependencies. On Debian/Ubuntu systems, at least libgstreamer1.0-dev and libgstreamer-plugins-base1.0-dev are required.

Requirements

Before submitting your PR, please make sure you addressed the following
requirements:

  • All commits in this PR have Signed-Off-By trailers (with
    git commit -s), and the commit message has max 60 characters for the
    summary and max 75 characters for each description line.
  • All added/changed functionality has a corresponding unit/integration
    test.
  • All added/changed public-facing functionality has entries in the "Upcoming
    Release" section of CHANGELOG.md (if no such section exists, please create one).
  • Any newly added unsafe code is properly documented.

@dorindabassey
Copy link
Collaborator

the build is failing because gstreamer-base-1.0 is missing from the build environment, looks like we need to update the rust-vmm container with gstreamer.

  pkg-config exited with status code 1
  > PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags gstreamer-base-1.0 'gstreamer-base-1.0 >= 1.20'
  The system library `gstreamer-base-1.0` required by crate `gstreamer-base-sys` was not found.
  The file `gstreamer-base-1.0.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  The PKG_CONFIG_PATH environment variable is not set.

@MatiasVara
Copy link
Contributor

the build is failing because gstreamer-base-1.0 is missing from the build environment, looks like we need to update the rust-vmm container with gstreamer.

  pkg-config exited with status code 1
  > PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags gstreamer-base-1.0 'gstreamer-base-1.0 >= 1.20'
  The system library `gstreamer-base-1.0` required by crate `gstreamer-base-sys` was not found.
  The file `gstreamer-base-1.0.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  The PKG_CONFIG_PATH environment variable is not set.

right, I just did it at rust-vmm/rust-vmm-ci#190

@stefano-garzarella
Copy link
Member

stefano-garzarella commented Sep 22, 2025

@nicholasdezai we just merged #881 that should bring @MatiasVara changes to add GStreamer deps to our CI container, please rebase this PR.

@nicholasdezai
Copy link
Author

I submitted a PR to rust-vmm-container to add the missing GStreamer dependencies
(gstreamer1.0-plugins-base and gstreamer1.0-plugins-good) required for running
the GStreamer backend tests in CI.

@stefano-garzarella
Copy link
Member

Please rebase this PR on main and keep dep updates (e.g. rust-vmm-ci submodule) in separate commits.

@nicholasdezai nicholasdezai force-pushed the gst branch 3 times, most recently from 121daab to b436032 Compare September 26, 2025 00:45
Copy link
Member

@stefano-garzarella stefano-garzarella left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for working on this and preparing the container for the CI!

I left some comments, in general I'd avoid unwrap()/expect(). I mean t's fine for the lock or something that should not happen, but for example you have in some places .ok_or(Error::StreamWithIdNotFound(stream_id))? and in others .expect("Can not find stream in stream_in.");. Why? (I didn't look the entire code, so maybe there is a reason).

@nicholasdezai nicholasdezai force-pushed the gst branch 3 times, most recently from 1e7e0fa to 859b44e Compare September 27, 2025 13:42
@nicholasdezai
Copy link
Author

I have improved the error handling in the new commit. I hope the error handling makes more sense now

@MatiasVara
Copy link
Contributor

I have tried both playback and recording. Both operations seem working.

@stefano-garzarella
Copy link
Member

@dorindabassey @epilys PTAL

@dorindabassey
Copy link
Collaborator

dorindabassey commented Oct 1, 2025

@dorindabassey @epilys PTAL

PR LGTM last time I checked, but I’ll do a more thorough review later(tomorrow).

Copy link
Contributor

@MatiasVara MatiasVara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@stefano-garzarella
Copy link
Member

@nicholasdezai please in the meantime rebase this on main, I guess you can remove the rust-vmm-ci commit since dependabot recently update it IIRC.

Copy link
Collaborator

@dorindabassey dorindabassey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @nicholasdezai for the work on this PR, I added just a few comments.

@dorindabassey
Copy link
Collaborator

dorindabassey commented Oct 3, 2025

Hi @nicholasdezai , I tested this on Fedora42 with kernel-6.14.0 I don't get any audio using the gstreamer backend, and running a simple aplay /usr/share/sounds/alsa/Front_Left.wav is stuck. attaching the logs incase it looks familiar.
RUST LOG debug vhost device.txt
btw, what image are you using to test?

@dorindabassey
Copy link
Collaborator

you also need to update the readme with the new backend

     --backend <BACKEND>
            audio backend to be used [possible values: null, pipewire, alsa]

@nicholasdezai
Copy link
Author

I’m testing with Debian 13 (trixie), kernel 6.15.5.

@MatiasVara
Copy link
Contributor

I just tried with qemu from master(29b77c1a2db2), Linux v6.16-rc1, and GStreamer 1.24.0, and it seems working.

@dorindabassey
Copy link
Collaborator

I used QEMU from master(517e9b4862cc), gstreamer 1.24.0, kernel 6.16.9, f42, also tried debian-13-nocloud-amd64.qcow2 image with gstreamer 1.24.0 i got no audio, but after updating to 1.24.13 it works with the debian image, so probably not an issue with the backend.

Add gstreamer backend.

Add gstreamer-related crates used in the vhost-device-sound
module

This affects only the vhost-device-sound module, and updates the
following dependencies:

- dependency-name: gstreamer
  dependency-version: 0.24.2
- dependency-name: gstreamer-app
  dependency-version: 0.24.2
- dependency-name: gstreamer-audio
  dependency-version: 0.24.2

Signed-off-by: nicholasdezai <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants